package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class 递增三元组 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=100010;
       static int a[]=new int[N],b[]=new int[N],c[]=new int[N],n;
       
       public static void main(String[] ss) throws NumberFormatException, IOException {
		      n=Integer.parseInt(br.readLine());
		      ss=br.readLine().split(" ");
		      for(int i=0;i<n;i++)
		    	  a[i]=Integer.parseInt(ss[i]);
		      ss=br.readLine().split(" ");
		      for(int i=0;i<n;i++)
		    	  b[i]=Integer.parseInt(ss[i]);
		      ss=br.readLine().split(" ");
		      for(int i=0;i<n;i++)
		    	  c[i]=Integer.parseInt(ss[i]);
		      Arrays.sort(a,0,n); Arrays.sort(b,0,n); Arrays.sort(c,0,n);
		      long res=0;
		      int ai=0,ci=0;
		      for(int i=0;i<n;i++){
		    	  while(ai<n&&a[ai]<b[i])ai++;
		    	  while(ci<n&&c[ci]<=b[i])ci++;
		    	  res+=ai*(n-ci);
		      }
		      System.out.print(res);
		      
	}
}
